{include file="inc/header_index_mui.html"}
<link href="css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/aui.css" />
<link rel="stylesheet" href="css/jianghu.css" />
<link rel="stylesheet" href="css/alert.css" />
<script src="js/jquery-1.8.2.min.js"></script>

		<div class="mui-content mui-text-center  ">
			
			<div style="padding-bottom: 50px;">
				<img class="aui-col-6 sai11" style="opacity: 0.8;" src="image/jianghu11.png" id="red11" />
				<h2 style="font-size: 26px; color: #ae6a0e;border: none;margin: 0;">武林争霸赛</h2>
			</div>
			<a name="10" id="10"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu1.png" />
				<img class="ab aui-col-2" style="top: -11px ;left: 36px;display:none" src="image/greenqi.png"  alt="" id="green10" />
				<img class="ab aui-col-2 sai10" style="top: -11px ;left: 105px;display:none" src="image/redqi.png"  alt="" id="red10" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-right:169px">第十关  登峰造极</h2>
				<div class="ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom: -76px;left: 36px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_10}人
				</div>
			</div>
			
			<a name="9" id="9"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu2.png" />
				<img class="ab aui-col-2" style="top: 31px ;right: 36px;display:none;" src="image/greenqi.png"  alt="" id="green9" />
				<img class="ab aui-col-2 sai9" style="top: 31px ;right: 105px;display:none;" src="image/redqi.png"  alt="" id="red9" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-left:118px">第九关 出神入化</h2>
				<div class="fr ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom:-76px;right: 90px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_9}人
				</div>
			</div>
			
			<a name="8" id="8"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu3.png" />
				<img class="ab aui-col-2" style="top: 31px ;left: 36px;display:none;" src="image/greenqi.png"  alt="" id="green8" />
				<img class="ab aui-col-2 sai8" style="top: 31px ;left: 105px;display:none;" src="image/redqi.png"  alt="" id="red8" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-right:169px">第八关 技冠群雄</h2>
				<div class="ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom: -76px;left: 36px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_8}人
				</div>
			</div>
			
			<a name="7" id="7"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu4.png" />
				<img class="ab aui-col-2" style="top: 31px ;right: 36px;display:none;" src="image/greenqi.png"  alt="" id="green7" />
				<img class="ab aui-col-2 sai7" style="top: 31px ;right: 105px;display:none;" src="image/redqi.png"  alt="" id="red7" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-left:118px">第七关 出类拔萃</h2>
				<div class="fr ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom:-76px;right: 90px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_7}人
				</div>
			</div>
			
			<a name="6" id="6"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu5.png" />
				<img class="ab aui-col-2" style="top: 31px ;left: 36px;display:none;" src="image/greenqi.png"  alt="" id="green6" />
				<img class="ab aui-col-2 sai6" style="top: 31px ;left: 105px;display:none;" src="image/redqi.png"  alt="" id="red6" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-right:169px">第六关 炉火纯青</h2>
				<div class="ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom: -76px;left: 36px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_6}人
				</div>
			</div>
			
			<a name="5" id="5"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu6.png" />
				<img class="ab aui-col-2" style="top: 31px ;right: 36px;display:none;" src="image/greenqi.png"  alt="" id="green5" />
				<img class="ab aui-col-2 sai5" style="top: 31px ;right: 105px;display:none;" src="image/redqi.png"  alt="" id="red5" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-left:118px">第五关 大显身手</h2>
				<div class="fr ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom:-76px;right: 90px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_5}人
				</div>
			</div>
			
			<a name="4" id="4"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu7.png" />
				<img class="ab aui-col-2" style="top: 31px ;left: 36px;display:none;" src="image/greenqi.png"  alt="" id="green4" />
				<img class="ab aui-col-2 sai4" style="top: 31px ;left: 105px;display:none;" src="image/redqi.png"  alt="" id="red4" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-right:169px">第四关 驾轻就熟</h2>
				<div class="ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom: -76px;left: 36px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_4}人
				</div>
			</div>
			
			<a name="3" id="3"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu8.png" />
				<img class="ab aui-col-2" style="top: 31px ;right: 36px;display:none;" src="image/greenqi.png"  alt="" id="green3" />
				<img class="ab aui-col-2 sai3" style="top: 31px ;right: 105px;display:none;" src="image/redqi.png"  alt="" id="red3" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-left:118px">第三关 小试牛刀</h2>
				<div class="fr ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom:-76px;right: 90px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_3}人
				</div>
			</div>

			<a name="2" id="2"></a>
			<div class="re">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu9.png" />
				<img class="ab aui-col-2" style="top: 31px ;left: 36px;display:none;" src="image/greenqi.png"  alt="" id="green2" />
				<img class="ab aui-col-2 sai2" style="top: 31px ;left: 105px;display:none;" src="image/redqi.png"  alt="" id="red2" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-right:169px">第二关 拜师学艺</h2>
				<div class="ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';bottom: -76px;left: 36px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_2}人
				</div>
			</div>

			<a name="1" id="1"></a>
			<div class="re" style="padding-bottom: 117px;">
				<img class="aui-col-10" style="opacity: 0.8;" src="image/jianghu10.png" />
				<img class="ab aui-col-2 " style="top: 31px ;right: 36px;display:none;" src="image/greenqi.png"  alt="" id="green1" />
				<img class="ab aui-col-2 sai1" style="top: 31px ;right: 105px;display:none;" src="image/redqi.png"  alt="" id="red1" />
				<h2 class="ab" style="color: #ae6a0e;border: none;padding-left:142px">第一关 初入江湖</h2>
				<div class="fr ab aui-color-white mui-text-center" style="width: 110px;height: 30px;background: #c5934f;border-radius: 12px;font: 16px/30px'';top:255px;right: 75px;">
					<img class="fl" style="margin: 9px 0 0 23px;" src="image/renshu.png" /> {$data.num_1}人
				</div>
			</div>
			<a name="0" id="0"></a>
			<!---->
			<div class="mx_alert" style="display:none">
				<div id="sai_red1" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">初入江湖</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('01')"><a class="aui-color-white" href="javascript:void(0)" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第一关-->
				<div id="sai_red2" class="ab  aui-col-9  mui-text-center" style="height: 350px;">

					<h1 class="aui-color-white sai-mar-t">拜师学艺</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('02')"><a class="aui-color-white"href="javascript:void(0)" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第二关-->
				<div id="sai_red3" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">小试牛刀</h1>


					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
					<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">

						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('03')"><a class="aui-color-white" href="javascript:void(0)" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第三关-->
				<div id="sai_red4" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">驾轻就熟</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('04')"><a class="aui-color-white" href="javascript:void(0)" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第四关-->
				<div id="sai_red5" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">大显身手</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
				<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('05')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第五关-->
				<div id="sai_red6" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">炉火纯青</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
					<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('06')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第六关-->
				<div id="sai_red7" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">出类拔萃</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						如果你无法简洁的表达你的想法，那只说明你还不够了解它。如果你无法简洁的表达你的想法，那只说明你还不够了解它。
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('07')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第七关-->
				<div id="sai_red8" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">技冠群雄</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						通关奖励
					</div>
					<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30"  onclick="queding('08')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第八关-->
				<div id="sai_red9" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">出神入化</h1>

					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						通关奖励
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30"  onclick="queding('09')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第九关-->
				<div id="sai_red10" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">登峰造极</h1>
					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
					通关奖励
					</div>
						<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30"  onclick="queding('10')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--第十关-->
				<div id="sai_red11" class="ab  aui-col-9  mui-text-center" style="height: 350px;">
					<h1 class="aui-color-white sai-mar-t">武林争霸赛</h1>
					<div class="ab aui-col-9  aui-background-white alert-lg-white mui-text-left" style="height: 140px;padding:20px 20px">
						通关奖励
					</div>
					<h2 class="aui-color-white" style="margin :150px 0 0 0">消耗 :xxx酒钱</h2>
					<div class="mui-row ab rebom aui-col-10 ">
						<div class="mui-col-sm-6 mui-col-xs-6 quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-5 aui-border-radius-30">取消</button>
						</div>
						<div class="mui-col-sm-6 mui-col-xs-6 ">
							<button type="button" class="mui-btn queding  mui-btn-warning aui-col-5 aui-border-radius-30" onclick="queding('11')"><a href="javascript:void(0)" class="aui-color-white" >我要挑战</a></button>
						</div>
					</div>
				</div>
				<!--武林争霸赛-->
				<div id="pipei" class="ab  aui-col-9 alert-lg-blue mui-text-center" style="display:none;">
					<h1 class="aui-color-white"><strong>江湖生涯-我要挑战</strong></h1>
					<div class="re aui-col-9 aui-background-white alert-lg-white mui-text-center">
						<img class="aui-col-2 aui-mar-t-20" src="images/pp_donghua.gif" alt="">
						<h2><strong>正在匹配...</strong> <img class="aui-col-1" src="images/shuaxin.gif" alt=""> </h2>
					</div>
					<h1 class="aui-color-white">满 <span id="numtxt2">16</span> 人开赛</h1>
					<h1 class="aui-color-white">已报名 <span id="bm_num">null</span> 人，还差 <span id="cha_num">null</span> 人</h1>
					<div class="quxiao mui-row  aui-col-10">
						<div class="quxiao ">
							<button type="button" class="mui-btn mui-btn-danger aui-col-6 aui-border-radius-30"  onclick="close_ws()">取消</button>
						</div>
					</div>
				</div>

			</div>

		</div>
		</div>
	</body>
<script>
for(var i=1;i<12;i++){
	$("#sai_red"+i).hide();//隐藏弹窗
	//添加红旗事件
	$("#red"+i).click(function() {
		$(".mx_alert").show();
		//alert("#sai_"+$(this).attr("id"));
		$("#sai_"+$(this).attr("id")).show();
	})
}
//添加弹窗取消事件
$(".mui-btn-danger").click(function() {
	$(".mx_alert").hide();
	$("#pipei").hide();
	for(var i=1;i<12;i++){
		$("#sai_red"+i).hide();
	}
})
//根据自己的段位显示红旗和绿旗
var dw={$data.my_dw};
if(dw<11){
	for(var i=1;i<12;i++){
		if(dw>i || dw==i){
			$("#green"+i).show();
		}	
	}
}
if(dw<10){
	$("#red"+(dw+1)).show();
}
//确定开始随机匹配
function queding(step){
	$("#deal_id").val("777777"+step);
	//alert(step*1);
	if(step=="11"){
		$("#buy_jiuliang").val(10000);
	}else{
		$("#buy_jiuliang").val(step*1*1000);
	}
	
	for(var i=1;i<12;i++){
		$("#sai_red"+i).hide();//隐藏弹窗
	}
	$(".mx_alert").show();
	$("#pipei").show();
	go(1);
}
</script>
<input type="hidden" value="" id="buy_jiuliang" />
<input type="hidden" value="" id="deal_id" />
<input type="hidden" value="1" id="isTrue" />
<script>
function go(type){//0创建房间 1快速匹配
	if($("#buy_jiuliang").val()*1>{$data.my_score}){
		alert('酒量不足，无法开始游戏');return;
	}else{
		var isTrue = $("#isTrue").val();
		
		var deal_id=$("#deal_id").val();
		if(isTrue=="1") {	
			var game_num=$("#numtxt2").html();
			//监听快速匹配玩家信息
			var join_group=deal_id+"-"+game_num+"-"+{$data.id};
			init(join_group);
		}
	}
}
</script>
<script>
var ws;
function init(join_group) {
	var host = "ws://47.104.8.67:8282";
	try {
		ws = new WebSocket(host);
		ws.onopen = function(){
			console.log('连接成功');
			ws.send("login:"+{$data.id});
			console.log('发送登陆数据完毕');
			ws.send("join_group:"+join_group);//join_group:deal_id-game_num-userid
			console.log('join_group通知完毕');
		};
		ws.onmessage = function (e) {
			//快速匹配监听 join_group-2
			if(e.data.indexOf("join_group")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				$("#bm_num").html(n[1]);
				$("#cha_num").html($("#numtxt2").html()-n[1]);
			}
			//监听退出事件 out_group-2
			if(e.data.indexOf("out_group")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				$("#bm_num").html(n[1]);
				$("#cha_num").html($("#numtxt2").html()-n[1]);
			}
			//监听人满开车
			if(e.data.indexOf("group_ok")>=0){
				console.log('开车啦');
				var n=e.data.split("-");
				var oneuser=n[1].split(",");
				if(oneuser[0]=={$data.id}){
					var deal_id =$("#deal_id").val();
					var game_num=$("#numtxt2").html();
					$.ajax({
						url: 'index.php?ctl=baozang&act=goumai2',
						type: 'POST',
						data: 'deal_id=' + deal_id + '&game_num=' + game_num + '&type=1&uids=' + n[1] +'&t=' + Math.random(),
						dataType: "json",
						success: function (data) {
							console.log(data);
							if(data.status=="1"){
								ws.send("doing:"+deal_id+"-"+game_num+"-"+data.deal_id);//发车成功 doing:deal_id-game_num-deal_id
							}else{
								alert(data.info);
							}
						},
						error: function () {
							//alert("系统错误，请联系管理员");
						}
					});				
				}
			}
			//监听发车成功
			if(e.data.indexOf("doing")>=0){
				var n=e.data.split("-");
				window.location.href='index.php?ctl=game&act=doing&deal_id='+n[1];
			}
			console.log('监听消息:'+e.data);
		};
		ws.onclose = function (msg) {
			console.log('关闭连接');
		};
	}
	catch (ex) {
		console.log(ex);
	}
}

function send(msg) {
	try { 
		ws.send(msg); 
	} catch (ex) { 
		console.log(ex);
	}
}
//刷新或关闭
window.onbeforeunload = function () {
	try {
		//监听异常退出事件
		var game_num=$("#numtxt2").html();
		var deal_id=$("#deal_id").val();
		ws.send("out_group:"+deal_id+"-"+game_num);//out_group:deal_id-game_num
		ws.close();
		ws = null;
	}
	catch (ex) {
		console.log(ex);
	}
};
//手动关闭
function close_ws(){
	try {
		//监听点击取消事件
		var game_num=$("#numtxt2").html();
		var deal_id=$("#deal_id").val();
		ws.send("out_group:"+deal_id+"-"+game_num);//out_group:deal_id-game_num
		ws.close();
		ws = null;
	}
	catch (ex) {
		console.log(ex);
	}
}
</script>		
</html>